-
Notifications
You must be signed in to change notification settings - Fork 139
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat(csharp): XML encode contents of <summary> and <example><code> code comments #4785
base: main
Are you sure you want to change the base?
Conversation
@@ -11,7 +11,7 @@ public record User | |||
public required string Id { get; set; } | |||
|
|||
/// <summary> | |||
/// The user's name. This name is unique to each user. A few examples are included below: | |||
/// The user's name. This name is unique to each user. A few examples are included below: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
it's looking like lodash's escape might be a little overkill for us -- from my understanding, lodash is going to escape the following chars: & < > " '
But I think that we only need carats to be escaped
Can we roll our own method that only escapes carats?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, I was on the fence about that. Let's do it ourselves.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@dcb6 The code has been updated with our own escaping.
…l-encode-csharp-comments
}); | ||
writer.writeLine("/// </code>"); | ||
writer.writeLine("/// </example>"); | ||
writer |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The DocXmlWriter
is awesome!
and overall i like the ideas that you're bringing here, such as this fluent writer API, but i'd prefer consistency with our existing writer. I'd also like to avoid adding new write
methods to our existing writer. So, I have a couple changes to propose:
- remove the
writeDocXml
method from theWriter
class and instead just initialize aDocXmlWriter
here (and elsewhere) - remove the fluent elements of the
DocXmlWriter
by simply have the methods returnvoid
, and changing the usages accordingly
I ack this is fairly opinionated, but I think we consider it more important to adhere to a consistent style than to introduce new patterns that bring fairly slight improvements
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done!
This part of the description is no longer accurate, correct?
|
Correct! |
When
<
and>
are used inside of summary or code example XML docs, the XML doc is invalid.This PR HTML encodes the contents before putting it in the XML doc.
This will also XML encode other characters which aren't really necessary, like"
, but IDEs continue to show the XML docs correctly.